package com.csgc.camera.widget.dialog

import android.content.Context
import android.view.View
import android.widget.LinearLayout

import com.csgc.camera.util.clickWithTrigger
import com.csgc.camera.widget.dialog.base.BottomDialog
import com.cysd.spsyxj.R


class EditImageDialog(val context: Context) {
    private lateinit var mDialog:BottomDialog
    var listener:OnOptionListener?=null
    private var removeMaskView:View?=null

    init {
        initDialog()
    }
    private fun initDialog(){

        mDialog = BottomDialog(context).apply {
            setCustomView(R.layout.dialog_edit_image)
            setOnDismissListener {
                listener?.onDismiss()
            }
            findViewById<LinearLayout>(R.id.tv_add_mask)?.clickWithTrigger {
                dismiss()
                listener?.onAddMask()
            }
            findViewById<LinearLayout>(R.id.tv_add_txt)?.clickWithTrigger {
                dismiss()
                listener?.onAddTxt()
            }
            findViewById<LinearLayout>(R.id.tv_add_label)?.clickWithTrigger {
                dismiss()
                listener?.onAddLabel()
            }
            removeMaskView = findViewById<View>(R.id.tv_remove_mask)
            removeMaskView?.clickWithTrigger {
                dismiss()
                listener?.onRemoveMask()
            }
        }
    }
    fun show(canRemoveMask:Boolean){
//        if (canRemoveMask){
//            removeMaskView?.visibility = View.VISIBLE
//        }else{
//            removeMaskView?.visibility = View.GONE
//        }
        mDialog.show()
    }

    //监听dismiss生命周期


    interface OnOptionListener{
        fun onAddMask()
        fun onAddTxt()
        fun onAddLabel()
        fun onRemoveMask()
        fun onDismiss ()
    }
}